﻿using Game2DFramework;
using MechGame.Game.Particles;
using Microsoft.Xna.Framework.Graphics;

namespace MechGame.Game.PlayerRobot
{
    class RocketWeapon : GameObject
    {
        private readonly ProjectileManager _projectileManager;
        private Texture2D _weaponTexture;
        private float _shootPauseTime;
        private readonly Player _player;

        public float RocketSpeed { get; private set; }
        public float ShootFrequency { get; private set; }

        public RocketWeapon(Player player, float rocketSpeed, float shootFrequency)
            : base(player.Game)
        {
            _player = player;
            _projectileManager = Game.GetGlobalObject<ProjectileManager>("ProjectileManager");
            RocketSpeed = rocketSpeed;
            ShootFrequency = shootFrequency;
        }

        public void Update(float elapsed)
        {
            if (!Game.Mouse.IsRightButtonDown()) _shootPauseTime += elapsed;
            if (!Game.Mouse.IsRightButtonDownOnce() || _shootPauseTime < ShootFrequency) return;
            _projectileManager.AddRocketProjectile(_player.Position, RocketSpeed, _player.CurrentLookDir, 5);
            _shootPauseTime = 0;
        }

        public void Draw()
        {
            
        }
    }
}
